/**
 * 
 */
var schoolId="";
$(function(){
	$('.tm-ul li').hover(function(){$(this).addClass('teamon')},function(){$(this).removeClass('teamon')});
	$('.tm-ul li').on('click',function(){$(this).parent().slideToggle('fast')});
	$('.tm-sel').on('click',function(){$(this).next().slideToggle('fast')});
	$('.tm-ul li').on('click',function(){$(this).parent().parent().find('.tm-sel').text($(this).text())});
	
	var zone_id=$("#zone_id").val();
	
	queryZoneIdBySchool(zone_id);
		$(".zoneId").click(function(e){
			var zoneId=e.currentTarget.id;
			/*$.ajax({
	            url: '/zone/queryCityByZoneId.yson',
	            type: 'post',
	            dataType: "json",
	            data: {zoneId: zoneId},
	            success: function (data) {
	                var citySelect = "";
	                $(data).each(function (i, obj) {
	                    citySelect +="<li id='cityLiId"+i+"' onclick='checkZone("+i+")' " +
	                    		     "onmousemove='mouseMoveZone("+i+")' onmouseout='mouseOutZone("+i+")' " +
	                    		     "value=" + obj.id + ">" + obj.name + "</li>";
	                });
	                $("#cityUi").empty().append(citySelect);
	            }
	        });*/
			window.location.href = "/team/teamWebList.html?zoneId="+zoneId;
			
		});
		
		$("#dp-search").click(function(){
			if(schoolId==""){
				alert("请选择学校");
				return false;
				
			}else if(schoolId!="" && schoolId!=null){
				window.location.href = "/team/teamWebList.html?schoolId="+schoolId;
			}
			
		});
		
		
		/*$(".query-teamData").click(function(e){
			var teamId=e.currentTarget.id;
			//var schoolId=$(this).val();
			//var schoolId=$(this).val();
			var schoolId=$(this).id;
			alert(schoolId);
			window.location.href = "/teamDate/queryTeamRoster.html?schoolId="+schoolId+"&teamId="+teamId;
			
		});*/
		
	});

function aClic(va){
	var teamId=va.id;
	var schoolId=va.name;
	window.location.href = "/teamDate/queryTeamRoster.html?schoolId="+schoolId+"&teamId="+teamId;

}



function checkZone(cityId){
	//$("#cityLiId"+i+"").parent().parent().find('.tm-sel').text($("#cityLiId"+i+"").text());
	//$("#cityLiId"+i+"").next().slideToggle('fast');
	//$("#cityLiId"+i+"").parent().slideToggle('fast');
	var cityId=i.value;
	$.ajax({
        url: '/playerDate/querySchoolByCityId.yson',
        type: 'post',
        dataType: "json",
        data: {cityId: cityId},
        success: function (data) {
            var schoolSelect = "";
            $(data).each(function (i, obj) {
            	schoolSelect +="<li id='schoolLiId"+i+"' onclick='checkTeam("+i+")' " +
                		     "onmousemove='mouseMoveCity("+i+")' onmouseout='mouseOutCity("+i+")' " +
                		     "value=" + obj.id + ">" + obj.name + "</li>";
            });
            $("#schoolUi").empty().append(schoolSelect);
        }
    });
}



function queryZoneIdBySchool(zoneId){
	$.ajax({
        url: '/playerDate/querySchoolByMap.yson',
        type: 'post',
        dataType: "json",
        data: {zoneId: zoneId},
        success: function (data) {
            var schoolSelect = "";
            $(data).each(function (i, obj) {
            	schoolSelect +="<li id='schoolLiId"+i+"' onclick='checkTeam("+i+")' " +
                		     "onmousemove='mouseMoveCity("+i+")' onmouseout='mouseOutCity("+i+")' " +
                		     "value=" + obj.id + ">" + obj.name + "</li>";
            });
            $("#schoolUi").empty().append(schoolSelect);
        }
    });
}





function checkTeam(i){
	$("#schoolLiId"+i+"").parent().parent().find('.tm-sel').text($("#schoolLiId"+i+"").text());
	$("#schoolLiId"+i+"").parent().slideToggle('fast');
	schoolId=$("#schoolLiId"+i+"").val();
}


function mouseMoveZone(i){
	$("#cityLiId"+i+"").addClass('teamon');
}
	
function mouseOutZone(i){
	$("#cityLiId"+i+"").removeClass('teamon');
}

function mouseMoveCity(i){
	$("#schoolLiId"+i+"").addClass('teamon');
}

function mouseOutCity(i){
	$("#schoolLiId"+i+"").removeClass('teamon');
}


